import { defineStore } from "pinia";
import { ref,reactive } from "vue";
import type LoginUser from "@/interfaces/LoginUser";

export const useUserStore = defineStore('user',()=>{
    /**
     * 登录状态,true已登录,false未登录
     */
    const loginState = ref(false)
    const user:LoginUser = reactive({
        id:-1,
        username:'',
        avatar:'',
        authorities:'',
        token:''
    })

    return {loginState,user}
    // 持久化，user的数据会本地化到localstorage中
},{persist: true})